﻿@model Tecnosop.WebUI.Models.createGuiaDespachoStep1

@{
    ViewBag.Title = "Nueva guía de despacho";
}
@section script {
    <script type="text/javascript">
        $("#clearButton").click(function (event) {
            event.preventDefault();
            $(":input:radio:checked").attr('checked', false);
            $(":input[name='NUMERO_FACTURA']").attr('value', "");
        });

        $(document).ready(function () {
            @if (ViewBag.EsConFacturaAsociada)
            {<text>
                 var initial_input = $("input[name='RazonSocial']:radio").val();
                 $("#EsRazonSocialTecnosop").val(initial_input);
                 $("#FormNuevaGuia").validate();
                 $("#FormNuevaGuia").valid();
            </text>}

            $("input[name='RazonSocialGuia']:radio").change(function () {
                var input = $(this).val();
                $("#EsRazonSocialTecnosopGuia").val(input);
                $("#FormNuevaGuia").validate();
                $("#FormNuevaGuia").valid();
            });

            $("input[name='RazonSocial']:radio").change(function () {
                var input = $(this).val();
                $("#EsRazonSocialTecnosop").val(input);
                $("#FormNuevaGuia").validate();
                $("#FormNuevaGuia").valid();
            });
        });
    </script>
}
@using (Html.BeginForm(MVC.GuiaDespacho.Create(), FormMethod.Post, new { id = "FormNuevaGuia" }))
{
    <fieldset>
        <legend>Datos iniciales</legend>

        <fieldset>        
         <legend style="font-size: small;">Datos guía de despacho</legend>
            <div style="margin-top: 10px;">@Html.ValidationMessageFor(model => model.EsRazonSocialTecnosopGuia)</div>

            @Html.HiddenFor(model => model.EsRazonSocialTecnosopGuia)  
            <div>@Html.RadioButton("RazonSocialGuia", true, false) Comercializadora Tecnosop</div> <br/>
            <div>@Html.RadioButton("RazonSocialGuia", false, false) Juan Carlos Maldonado Huerta</div>

            <div class="editor-label">
            @Html.LabelFor(model => model.ID_GUIA_DE_DESPACHO_)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.ID_GUIA_DE_DESPACHO_)
            @Html.ValidationMessageFor(model => model.ID_GUIA_DE_DESPACHO_)
        </div>
        </fieldset>

         
          

         <fieldset>
         <legend style="font-size: small;">Datos factura</legend>
            <div style="margin-top: 10px;"></div>

            @Html.HiddenFor(model => model.EsRazonSocialTecnosop) 
            @if (Model != null && Model.NUMERO_CONVENIO.HasValue==false)
            {
                <div>@Html.RadioButton("RazonSocial", true, Model.RAZON_SOCIAL.Equals("Comercializadora Tecnosop")) Comercializadora Tecnosop</div> <br/>
                <div>@Html.RadioButton("RazonSocial", false, Model.RAZON_SOCIAL.Equals("Juan Carlos Maldonado Huerta")) Juan Carlos Maldonado Huerta</div>
            }
            else
            {
                <div>@Html.RadioButton("RazonSocial", true, false) Comercializadora Tecnosop</div> <br/>
                <div>@Html.RadioButton("RazonSocial", false, false) Juan Carlos Maldonado Huerta</div>
            }

            <div class="editor-label">@Html.LabelFor(model => model.NUMERO_FACTURA)</div>
            <div class="editor-field">
                @Html.EditorFor(model => model.NUMERO_FACTURA)
                @Html.ValidationMessageFor(model => model.NUMERO_FACTURA)
            </div>
        <button id="clearButton">Limpiar</button>
        </fieldset>


        
        <div class="editor-label" style="margin-top: 0px">
            @Html.LabelFor(model => model.REGION)
        </div>        
        <div class="editor-field">
            @*@Html.DropDownList("REGION", String.Empty)*@
            @(Html.Telerik().DropDownList()
                .Name("REGION")
                .HtmlAttributes("width: 250px")
        //.Items(item => item.Add().Text(String.Empty))
                .SelectedIndex(0)
                .BindTo(ViewBag.REGIONES)
            )
            @Html.ValidationMessageFor(model => model.REGION)
        </div>

          <div class="editor-label">
            @Html.LabelFor(model => model.CIUDAD)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.CIUDAD)
            @Html.ValidationMessageFor(model => model.CIUDAD)
        </div>


        
          <div class="editor-label">
            @Html.LabelFor(model => model.COMUNA)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.COMUNA)
            @Html.ValidationMessageFor(model => model.COMUNA)
        </div>

        
          <div class="editor-label">
            @Html.LabelFor(model => model.DIRECCION_DE_DESPACHO)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.DIRECCION_DE_DESPACHO)
            @Html.ValidationMessageFor(model => model.DIRECCION_DE_DESPACHO)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.COMENTARIO)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.COMENTARIO)
            @Html.ValidationMessageFor(model => model.COMENTARIO)
        </div>

             <br />
              <button type="submit" class="nice radius small blue button">Siguiente ></button>
        </fieldset>
   
}
